local actionBarOnUseActionBarObject = ActionBar.OnUseActionBarObject;

function ActionBar.OnUseActionBarObject(box)
	if box:IsEmpty() then
		return
	end
	box:SetObjectStaring(false)
	local player = GetClientPlayer()

	local nObjectType = box:GetObjectType()
    if nObjectType == UI_OBJECT_ITEM_INFO then
    	local _, dwV, dwT, dwI = box:GetObjectData()
    	local dwBox, dwX = player.GetItemPos(dwT, dwI)
    	if dwBox and dwX then
    		OnUseItem(dwBox, dwX, box)
    	end
    elseif nObjectType == UI_OBJECT_ITEM then
    	local _, dwBox, dwX = box:GetObjectData()    	
		if dwBox == INVENTORY_INDEX.EQUIP then
			local item = player.GetItem(dwBox, dwX)
			if item and item.nSub == EQUIPMENT_SUB.PACKAGE then
				if IsBagPanelOpened(EquipIndexToBagPanelIndex(dwX)) then
					CloseBagPanel(EquipIndexToBagPanelIndex(dwX))
				else
					OpenBagPanel(EquipIndexToBagPanelIndex(dwX))
				end
			else
				OnUseItem(dwBox, dwX, box)
			end
		else
			local item = player.GetItem(dwBox, dwX)
			if item and item.nGenre == ITEM_GENRE.EQUIPMENT then
				local eRetCode, nEquipPos = player.GetEquipPos(dwBox, dwX)
				if eRetCode == ITEM_RESULT_CODE.SUCCESS then
					OnExchangeItem(dwBox, dwX, INVENTORY_INDEX.EQUIP, nEquipPos)
					PlayItemSound(item.nUiId)
				else
					OutputMessage("MSG_ANNOUNCE_RED", g_tStrings.tItem_Msg[eRetCode])
				end
			else
				OutputMessage("MSG_ANNOUNCE_RED", g_tStrings.SRT_ERROR_CAN_NOT_EQUIP)
			end
		end
    elseif nObjectType == UI_OBJECT_SKILL then
		local dwSkillID, dwSkillLevel = box:GetObjectData()
		OutputMessage("MSG_ANNOUNCE_RED",GetKeyName(Station.GetMessageKey()));
		--[[
		if GetKeyName(Station.GetMessageKey()) == 2 then
			
		end
		--]]
		StrafeRightStart()
		OnUseSkill(537, 5, box)
		OnUseSkill(dwSkillID, dwSkillLevel, box)
		StrafeRightStop()
    elseif nObjectType == UI_OBJECT_CRAFT then
    	local nProID, nBranchID, nCraftID = box:GetObjectData()
		OnUseCraft(nProID, nBranchID, nCraftID, box)
	elseif nObjectType == UI_OBJECT_SYS_BTN then
		local dwID = box:GetObjectData()
		OnUseSysBtn(dwID)
    end
end